package cn.chencaiju.algorithm;

import java.util.Arrays;

public class ArrayPairs {

	public static void main(String[] args) {
		int[] nums= {1,4,3,2,9,0};
		System.out.println("sum="+arrayPairSum(nums));

	}
    public static int arrayPairSum(int[] nums) {
    	Arrays.sort(nums);
    	System.out.println(Arrays.toString(nums));
    	int sum=0;
    	for(int i=nums.length-2;i>-1;i-=2) {
    		sum+=nums[i];
    		System.out.println("("+nums[i+1]+","+nums[i]+")");
    	}
    	return sum;
    }

}
